package com.itheima.Thraed.ThreadPrinciple;

public class demo8 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() ->{
            while (true){
                if(Thread.currentThread().isInterrupted()){
                    break;
                }
                System.out.println("借宿");
            }
        });
        // 设置为守护线程，非守护线程运行结束后，守护线程不管有没有运行完，都会结束
        t1.setDaemon(true);
        t1.start();
        Thread.sleep(1000);
        System.out.println("借宿");
    }
}
